import { defineStore } from 'pinia'
import { login as logins } from '../api/adminApi'
import { Admin, Token } from '../api/entity/admin'
import { Menu } from '../api/entity/Menu'

//定义容器
export const MainStore = defineStore('main', {
    state: () => {
        return {
            user: [] as Admin[],
            token: window.localStorage.getItem("token"),
            menu: []
        }
    },
    getters: {
    },
    actions: {
        login(user: Admin) {
            this.$patch(state => {
                logins(user).then(c => {
                    //   this.token=c.token;
                    //   console.log(this.token);
                    window.localStorage.setItem("token", c.token)
                })

            })

        }
    }
})
